import request from '@/utils/request'

// 创建教学课时
export function createCourseHours(data) {
  return request({
    url: '/api/course-hours',
    method: 'post',
    data
  })
}

// 更新教学课时
export function updateCourseHours(id, data) {
  return request({
    url: `/api/course-hours/${id}`,
    method: 'put',
    data
  })
}

// 删除教学课时
export function deleteCourseHours(id) {
  return request({
    url: `/api/course-hours/${id}`,
    method: 'delete'
  })
}

// 根据ID获取教学课时
export function getCourseHours(id) {
  return request({
    url: `/api/course-hours/${id}`,
    method: 'get'
  })
}

// 获取我的教学课时
export function getMyCourseHours() {
  return request({
    url: '/api/course-hours/my',
    method: 'get'
  })
}

// 获取所有教学课时（管理员用）
export function getAllCourseHours() {
  return request({
    url: '/api/course-hours/all',
    method: 'get'
  })
}

// 根据学年学期获取教学课时
export function getCourseHoursByAcademicYear(academicYear) {
  return request({
    url: `/api/course-hours/academic-year/${encodeURIComponent(academicYear)}`,
    method: 'get'
  })
}

// 根据教师姓名获取教学课时
export function getCourseHoursByUserName(userName) {
  return request({
    url: `/api/course-hours/user/${encodeURIComponent(userName)}`,
    method: 'get'
  })
}

// 根据教师姓名和学年学期获取教学课时
export function getCourseHoursByUserNameAndAcademicYear(userName, academicYear) {
  return request({
    url: `/api/course-hours/user/${encodeURIComponent(userName)}/academic-year/${encodeURIComponent(academicYear)}`,
    method: 'get'
  })
}

// 获取学年学期统计
export function getStatisticsByAcademicYear(academicYear) {
  return request({
    url: `/api/course-hours/statistics/academic-year/${encodeURIComponent(academicYear)}`,
    method: 'get'
  })
}

// 获取用户统计
export function getStatisticsByUserId(userId) {
  return request({
    url: `/api/course-hours/statistics/user/${userId}`,
    method: 'get'
  })
}

// 获取教师列表（用于筛选）
export function getTeachersList() {
  return request({
    url: '/api/course-hours/teachers',
    method: 'get'
  })
}

// 获取学年学期配置
export function getSemesterConfig() {
  return request({
    url: '/api/course-hours/semester-config',
    method: 'get'
  })
}
